home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-29 | 12.2 KB | 432 lines | [SGPA/SCPG] |
- on startup
-
- if toolmode = "texttool" then
- answer "Select one or more graphic objects with the arrow tool."
- exit startup
- end if
-
- set shuffleTextObjects to false
-
- set lockcursor to true
- set mousecursor to watch
- set lockscreen to true
-
- progressDialog open
- progressDialog show, "Searching for Captionable graphics…"
- put true into zoomed
- put toolmode into oldTool
- put currentpage into theOldPage
- put 0 into totalCaptions
- put displayGuides into oldGuides
- set displayGuides to true
- put 25 into CaptionVSize -- In points.
- put false into MadeCaptions -- Any captions made yet?
-
- put measurements into OldMeasurements
- set measurements to points
-
- -- Assign data to objects
- repeat with x = 1 to number of items in selectedObjects()
- if kind of object item x of selectedObjects() = "Grayscale Graphic" or¬
- kind of object item x of selectedObjects() = "PICT Graphic" or ¬
- kind of object item x of selectedObjects() = "eps graphic" or¬
- kind of object item x of selectedObjects() = "bitmap graphic" or¬
- kind of object item x of selectedObjects() = "quicktime Movie" or¬
- kind of object item x of selectedObjects() = "rectangle" or¬
- kind of object item x of selectedObjects() = "oval" or¬
- kind of object item x of selectedObjects() = "rounded rectangle" then
-
- put 1+totalCaptions into TotalCaptions
- -- Pre-Assign text of caption
- set itemdel to numtochar(1)
- put "Type Caption for Graphic here." into item TotalCaptions of TextOfCaptions
- set itemdel to ","
-
- -- Assign Page of Caption Graphic.
- put currentPage into item totalCaptions of pagesOfCaptions
- -- Assign Caption Graphic Object Number of the page.
- put (item x of selectedObjects()) into item totalCaptions of CaptionObjects
- -- Assign name of Caption Object
- put "Caption " & ticks() into theCaptionName
- put theCaptionName into item totalCaptions of CaptionTextObjNames
- -- Assign name of Caption Story
- put theCaptionName & ".S" into item totalCaptions of CaptionStoryNames
- -- Assign name of Caption Line Object
- put theCaptionName & ".L" into item totalCaptions of CaptionLineNames
- end if
- end repeat
- progressDialog close
-
- set measurements to OldMeasurements
-
- if totalCaptions < 1 then
- answer "No graphic objects are selected. Select the graphics to caption."
- set toolmode to oldtool
- set currentpage to theoldPage
- set measurements to oldMeasurements
- exit startup
- end if
-
-
- -- Run the dialog.
-
- put dialog(preload, 506) into theDialog
-
- -- Action proc for Headline Entry Box
- SetDialogItem 6, Box
- -- Action proc for Create Caption box.
- SetDialogItem 23, Box
- -- Action proc for Text Proxie
- SetDialogItem 11, Box
- -- Action for graphic preview
- SetDialogItem 2, Box
-
-
- put 1 into CurrentCaption
- setDialogItem 5, set
-
- repeat forever -- Do all caption objects.
- put true into DoUpdate
-
- -- Handle the dialog.
- repeat forever
-
- -- Check if we need to update the dialog data.
- if DoUpdate then
-
- -- If the user has made any changes, add "…" to cancel button
- if MadeCaptions then
- setDialogItem 19,contents, "Cancel…"
- end if
-
- -- Get current Captions' Data
- set itemdel to numtochar(1)
- setDialogItem 5, contents, item currentCaption of TextOfCaptions
- set itemdel to ","
-
- -- Go to the Captions' page
- set currentpage to item currentCaption of pagesOfCaptions
- put item currentCaption of CaptionObjects into theCaptionObject
-
- -- Caption off page? or Too many objects?
- set measurements to points
- if number(objects) > 197 then
- put true into TooManyObjects
- else
- put false into TooManyObjects
- end if
-
- put rect of object (item currentCaption of CaptionObjects) into theObjRect
- if (item 4 of theObjRect) + CaptionVSize > pageHeight then
- put true into CaptionOffPage
- else
- put false into CaptionOffPage
- end if
-
- if TooManyObjects or CaptionOffPage then
- setDialogItem 21, disabled
- if TooManyObjects then
- setDialogItem 13, text, cr & cr & "Adding a caption would exceed "&¬
- "the maximum number of objects allowed on a page. Delete some objects "¬
- and try this addition again."
- else
- setDialogItem 13, text, cr & cr & "There is not enough room to place "&¬
- "a caption below this graphic. Please move or resize the graphic object."
- end if
- else
- setDialogItem 21, enabled
- setDialogItem 13, disabled
- end if -- Caption off page?
-
-
- setDialogItem 9, graphic, theCaptionObject & ",p"
-
- -- Is there an object for caption text preview?
- set measurements to points
- if exists(object (item currentCaption of CaptionTextObjNames)) then
- put number of object (item currentCaption of CaptionTextObjNames) into¬
- CaptionTextObj
- -- Preset the text of the caption
- SetDialogItem 13, graphic, CaptionTextObj & ",p"
- SetDialogItem 21, set -- Make a caption.
- SetDialogItem 22, clear -- dont Make a caption.
- setDialogItem 16, enabled -- Include Dividing Line
- setDialogItem 15, enabled -- Update Text Preview
- else
- SetDialogItem 21, clear -- Make a caption.
- SetDialogItem 22, set -- dont Make a caption.
- setDialogItem 16, disabled -- Include Dividing Line
- setDialogitem 15, disabled -- Update Text Preview
- end if
- set measurements to oldMeasurements
-
- -- Show current page number
- setDialogItem 18, contents, currentpage
-
- -- Is there a caption on the page yet?
- if exists( object (item currentCaption of CaptionTextObjNames) ) then
- setDialogItem 21, set -- create a caption
- setDialogItem 22, clear -- Dont create a caption.
- set itemdel to numtochar(1)
- --set caption text entry.
- setDialogItem 5, contents, item currentCaption of TextOfCaptions
- set itemdel to ","
- -- Set text preview.
- setDialogItem 13, graphic, ¬
- number of object (item currentCaption of CaptionTextObjNames) & ",p"
- else
- setDialogItem 22, set -- dont create a caption
- setDialogItem 21, clear -- Create a caption
- set itemdel to numtochar(1)
- --set caption text entry.
- setDialogItem 5, set, contents, item currentCaption of textOfCaptions
- set itemdel to ","
- setDialogItem 15, disabled -- UpdateTextPreview
- end if
-
-
- -- Set state of navigator buttons (Prev & Next)
- if totalCaptions < 2 then
- setDialogItem 20, disabled
- setDialogItem 14, disabled
- else
- if currentCaption = 1 then
- setDialogItem 20, disabled
- setDialogItem 14, enabled
- end if
- if CurrentCaption = totalCaptions then
- setDialogItem 20, enabled
- setDialogItem 14, disabled
- end if
- if (currentCaption ≠ 1) and (currentCaption ≠ totalCaptions) then
- setDialogItem 20, enabled
- setDialogItem 14, enabled
- end if
- end if
-
- -- Force update of text preview
- setDialogItem 2, box
- if exists(object (item currentCaption of CaptionTextObjNames)) then
- SetDialogItem 13, graphic, ¬
- number of object (item currentCaption of CaptionTextObjNames) & ",p"
- end if
-
- -- Force update of Graphic to Caption
- SetDialogItem 9, graphic, item currentCaption of CaptionObjects & ",p"
- set measurements to oldMeasurements
- put false into DoUpdate
- end if -- Do Update
-
-
- get dialog(display, theDialog)
- set lockcursor to true
- Set mousecursor to "watch"
-
- switch it
-
- case 22 -- No Caption.
- -- Delete Caption Object
- if exists(object (item currentCaption of CaptionTextObjNames)) then
- delete object (item CurrentCaption of CaptionTextObjNames)
- end if
- -- Delete Caption Line Object
- if exists(object (item currentCaption of CaptionLineNames)) then
- delete object (item currentCaption of CaptionLineNames)
- end if
-
- setDialogItem 15, disabled
- setDialogItem 11, box -- Text Preview, force update
- setDialogItem 16, disabled
- put true into DoUpdate
- exit switch
-
- case 21 -- Create Caption.
- set itemdel to numtochar(1)
- put contentsOf(item5) into item CurrentCaption of textOfCaptions
- set itemdel to ","
- put true into MadeCaptions
- -- Create Caption text object & line.
- if not exists(object (item currentCaption of CaptionTextObjNames)) then
- set measurements to points
- put rect of object (item currentCaption of CaptionObjects) into theCaptionRect
- set stylerecomposition to false
- open story item currentCaption of CaptionStoryNames
- draw rectangle from item 1 of theCaptionRect, item 4 of theCaptionRect to ¬
- item 3 of theCaptionRect, item 4 of theCaptionRect + CaptionVSize
- close story
- set name of last object to (item currentCaption of CaptionTextObjNames)
- set linePattern of last object to 0
- set fillPattern of last object to 2
- set frameLineType of last object to 1
- set textwrap of last object to 20 aroundRect
- set stylerecomposition to true
- set itemdel to numtochar(1)
- put item CurrentCaption of textOfCaptions into theStoryText
- set itemdel to ","
- put theStoryText into story item currentCaption of CaptionStoryNames
- copyfit story (item currentCaption of CaptionStoryNames)
- set measurements to oldMeasurements
- -- Update text preview.
- setDialogItem 9, graphic, ¬
- number of object (item currentCaption of CaptionTextObjNames) & ",p"
- end if
- put true into DoUpdate
- exit switch
-
- case 19 -- Cancel
- -- Check if user made any captions...
-
- put true into CancelNow
- if MadeCaptions then
- answer "Cancelling now will erase all captions that have been entered. Do you" &¬
- " really want to cancel?" with "Yes" or "No"
- if it is "yes" then
- progressDialog open
- set lockscreen to true
- set styleRecomposition to false
- repeat with c = 1 to totalCaptions
- progressDialog show, "Deleting Caption " & c & " of " & totalCaptions & "…"
-
- -- Goto Page of Caption.
- set currentPage to item c of pagesOfCaptions
- -- Delete Caption Object
- if exists(object (item c of CaptionTextObjNames)) then
- delete object (item c of CaptionTextObjNames)
- end if
- -- Delete Caption Line Object
- if exists(object (item c of CaptionLineNames)) then
- delete object (item c of CaptionLineNames)
- end if
- end repeat -- c=1 to totalcaptions
- progressDialog close
- set lockscreen to false
- put true into CancelNow
-
- else
- put false into CancelNow
- end if -- it = yes
- end if -- madeCaptions?
-
- if CancelNow then
- set styleRecomposition to true
- set currentPage to theoldPage
- set toolmode to oldTool
- set measurements to oldMeasurements
- exit startup
- end if
- exit switch
-
- case 20 -- Prev Caption
- case 14 -- Next Caption
- case 10 -- OK Button
- case 15 -- Update Text Preview
- -- Set the text of the caption & Store the text into the list.
- if hilited(item21) then
- put contentsOf(item5) into newCaptionText
- set itemdel to numtoChar(1)
- put newCaptionText into item CurrentCaption of textOfCaptions
- set itemdel to ","
- put newCaptionText into story (item currentCaption of CaptionStoryNames)
- copyfit story (item currentCaption of CaptionStoryNames)
- end if
-
- if it = 15 then
- setDialogItem 9, graphic, ¬
- number of object (item currentCaption of CaptionTextObjNames) & ",p"
- end if
-
- case 16 -- Include dividing line?
- if it = 16 then
- put hilited(item16) into dividingLine
-
- if dividingLine then
- set measurements to points
- -- Create the dividing line
- if not exists(object (item currentCaption of CaptionLines)) then
- draw line from (item 1 of theCaptionRect), ¬
- (item 4 of theCaptionRect+CaptionVSize-1)¬
- to (item 3 of theCaptionRect), (item 4 of theCaptionRect+CaptionVSize-1)
- set frameLineType of last object to 1
- set linepattern of last object to 1
- set name of last object to (item currentCaption of CaptionLineNames)
- set measurements to oldMeasurements
- end if
- else
- -- Delete dividing line.
- if exists(object (item currentCaption of CaptionLines)) then
- delete object (item currentCaption of CaptionLines)
- end if
- end if -- dividing line?
-
- end if -- it=16
-
- if it = 10 then exit repeat -- OK Button
- if it = 20 then -- Prev
- put contentsOf(item5) into StoryText
- set itemdel to numtoChar(1)
- put StoryText into item CurrentCaption of textOfCaptions
- set itemdel to ","
- put currentCaption - 1 into CurrentCaption
- if currentCaption < 1 then put 1 into CurrentCaption
- setDialogItem 5,set
- end if
- if it = 14 then -- Next
- put contentsOf(item5) into StoryText
- set itemdel to numtoChar(1)
- put StoryText into item CurrentCaption of textOfCaptions
- set itemdel to ","
- put currentCaption + 1 into CurrentCaption
- if currentCaption > totalCaptions then put totalCaptions into currentCaption
- setDialogItem 5, set
- end if
- SetDialogItem 11, box -- Text Preview Box.
-
-
- case 25
- if it = 25 then
- helpdialog 128, "Caption Help"
- end if
-
- put true into DoUpdate
- exit switch
-
- end switch -- Item Hit (it)
-
- end repeat -- Dialog Handler.
-
- if it = 10 then exit repeat -- Ok Button.
- end repeat -- Every Caption.
-
- set displayGuides to oldGuides
- set toolmode to oldTool
- set currentPage to theoldPage
- set measurements to oldMeasurements
-
- End startup
-
- function contentsof thedata
- put itemdel into OldItemDel
- set itemdel to "\"
- get item 2 of thedata
- set itemdel to OldItemDel
- return it
- end contentsof
-
- function hilited thedata
- return (char 4 of thedata = "s")
- end hilited
-
- on help
- put dialog (preload, 128) into thedialog
- put "---a\0" into item2
- put "---a\1" into item3
- put "---a\2" into item4
-
-
- repeat forever
- get dialog(display, thedialog)
- if (it = 1) then exit repeat
- end repeat
- get dialog(dispose, thedialog)
- end help